package main

import (
	"fmt"
	"math/rand"
	"time"
)

func main() {
	rand.Seed(time.Now().UnixNano())

	const totalTasks = 100
	const workerCount = 1000

	taskQueue := make(chan Task, 100)

	// 投任务
	go func() {
		for i := 1; i <= totalTasks; i++ {
			task := Task{
				ID:      i,
				Payload: fmt.Sprintf("payload-%d", i),
			}
			taskQueue <- task
		}
		close(taskQueue)
	}()

	// 启动调度器
	resultChan := DispatchTasks(taskQueue, workerCount)

	// 主程序收集结果
	for res := range resultChan {
		fmt.Println("🎯", res)
	}

	fmt.Println("✅ 所有任务处理完毕")
}
